class LoginController < ApplicationController
  def index
    session[:user_id] = nil
    if request.post?
      user = User.authenticate(params[:name], params[:password])
      #is_authenticated = (params[:name] == "lz" && params[:password] == "502")
      if user
        session[:user_id] = params[:name]
#        puts params[:url]
#        if params[:url].blank?
        redirect_to(:controller => "tour_groups")
#        else
#          redirect_to params[:url]
#        end
      else
        flash[:notice] = "用户名或密码错误，请重新输入。"
      end
    end
  end
end
